/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Logic.User;

import Entities.User;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author marcy
 */
@Deprecated
public class Autenticazione_User {

    private User user;

    public Autenticazione_User(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
        
        user = (User) session.getAttribute("User");
        if (user == null) {
            user = new User();
            session.setAttribute("User", user);
        } else {
            switch (user.getGruppo()) {
                case 3:
                    try {
                        response.sendRedirect(request.getContextPath()+"/protected/medic/Medic_login.jsp");
                    } catch (IOException ex) {
                        Logger.getLogger(Autenticazione_User.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    break;
                case 2:
                    try {
                        response.sendRedirect(request.getContextPath()+"/protected/paziente/Paziente_login.jsp");
                    } catch (IOException ex) {
                        Logger.getLogger(Autenticazione_User.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    break;
                case 1:
                    break;
                default:
                    break;
            }
        }
    }
}
